package com.example.demoioc;

import com.example.demoioc.controller.UserController;
import com.example.demoioc.service.UserService;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;

@SpringBootApplication
public class DemoIoCApplication {

    public static void main(String[] args) {
        // 获取 spring 上下文对象
        ApplicationContext context = SpringApplication.run(DemoIoCApplication.class, args);
        // 从 Spring 上下文中获取对象
        UserService userService = context.getBean(UserService.class);
        userService.sayHi();
    }

}
